package control;

import model.MiljoBoven;
import view.MainFrame;

/**
 * Handles the communication between the model and the view.
 *
 * @author Kevin
 */
public class MainController
{

    private final MiljoBoven model;
    private final MainFrame view;
    private final LoginPanelListener loginListener;
    private final MainPanelListener mainPanelListener;
    private final DetailedPanelListener detailedPanelListener;

    /**
     * Class constructor
     *
     * @param mainFrame application frame
     * @param miljoBoven application model
     */
    public MainController(MainFrame mainFrame, MiljoBoven miljoBoven)
    {
        this.model = miljoBoven;
        this.view = mainFrame;

        this.loginListener = new LoginPanelListener(this.view, this.model, this.view.getLoginPanel());
        this.mainPanelListener = new MainPanelListener(this.view, this.model, this.view.getMainPanel());
        this.detailedPanelListener = new DetailedPanelListener(this.view, this.model, this.view.getDetailedPanel());

        //actionListener for loginPanel
        this.view.getLoginPanel().addLoginPanelListener(loginListener);

        //actionListeners for mainPanel
        this.view.getMainPanel().addListenerForNewCaseButton(mainPanelListener);
        this.view.getMainPanel().addListenerForLogutButton(mainPanelListener);
        this.view.getMainPanel().addListenerForMouse(mainPanelListener);

        //actionListener for detailedPanel
        this.view.getDetailedPanel().addDetailedPanelListener(detailedPanelListener);
    }
}
